//
//  HMWelcomeViewController.swift
//  Weibo-walker
//
//  Created by 郭彬 on 16/3/5.
//  Copyright © 2016年 guobin. All rights reserved.
//

import UIKit

class HMNewfeatureViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupUI()
        
    }
    //MARK: - 创建 scoller
    func setupUI() {
        
        scrollView.frame = view.bounds
        
        pageControl.frame = CGRect(x: scrollView.frame.width * 0.5  , y: scrollView.frame.height - 100, width: 0, height: 0)
        
        view.addSubview(scrollView)
        
        view.addSubview(pageControl)
        
        
        view.backgroundColor = UIColor.grayColor()
        
        
        
        let count = 4
        
        for i in 0...4 {
            scrollView.contentSize = CGSize(width: CGFloat(count) * scrollView.frame.width, height: 0)
            

        let image = UIImageView(image: UIImage(named:"new_feature_\(i + 1)" ))
                scrollView.backgroundColor = UIColor.greenColor()
            
        image.frame = CGRect(x: CGFloat(i) * view.frame.width, y: 0, width: view.frame.width, height: view.frame.height)

        scrollView.addSubview(image)

        // 页数
        pageControl.numberOfPages = count
            
            if i == 3 {
                
                let button = UIButton()
                

                button.setImage(UIImage(named: "new_feature_finish_button_highlighted"), forState: .Normal)
                
                button.setImage(UIImage(named: "new_feature_finish_button_highlighted"), forState: .Highlighted)
                
                
                button.frame = CGRect(x: 0, y: 300, width: 300, height: 50)
                
               self.view.addSubview(button)
                
            }
            
        }


    }
    
    //MARK: - 懒加载 scrollView
    lazy var scrollView :UIScrollView = {
        
        let scrollView = UIScrollView()
        
        
//        scrollView.bounds = false
        
        scrollView.showsHorizontalScrollIndicator = false
        
        

        
        return scrollView
        
    }()
    
    //MARK: - 懒加载 pageControl

    lazy var pageControl :UIPageControl = {
       
        let pageControl = UIPageControl()
        
        pageControl.numberOfPages = 4
        
        pageControl.currentPageIndicatorTintColor = UIColor.redColor()
        
        pageControl.pageIndicatorTintColor = UIColor.whiteColor()
        
        pageControl.enabled = false
        
        return pageControl
        
    }()

    



    }
